
#include <stdio.h>
#include "STLOG.h"
#include "STL_Text.h"
#include "STL_Crypt_DES3.h"
#include "STL_Base64.h"
#include <string>

using namespace STL;

/**
 * @brief 
 * 
 * 加密模式：ECB,CBC,CTR,OFB,CFB
 * 块大小block：
 * 填充方式：pkcs5padding,pkcs7padding,zeropadding,iso10126,ansix923,no padding
 * 加密密匙KEY：julong.www.ss360.org0000
 * 加密偏移量IV：12345678
 * 输出方式：Base64，hex
 * 
 * @param argc 
 * @param argv 
 * @return int 
 */
int main(int argc, char *argv[])
{
    // printf("Hello World!\n");
    //加密模式: CBC
    //填充方式: pkcs5
    //输出方式：Base64

    std::string data = "adfasdfasdfasdlkfjieidjvklxcjivojeofkjasdkljfiejklsadjfijewijasdlkfji8ewjlaksdjfkiljajjjj12k3j1239012u903uj @ !@e dj01 z329 9x12 z3u29803 *(#!@u#@9 (@$uZZZZZZZZZZZZZZZZZ";
    std::string key = "julong.www.ss360.org0000";
    std::string iv = "12345678";
    stlog_debug("data:%s", data.c_str());
    std::string encode = encrypt_des_ede3_cbc_pkcs5(data, key, iv);
    stlog_debug("encode:%s", STL_Text::StringToHexString(encode).c_str());
    std::string base64 = base64Encode(encode);
    stlog_debug("base64:%s", base64.c_str());
    std::string newData = decrypt_des_ede3_cbc_pksc5(encode, key, iv);
    stlog_debug("newData:%s", newData.c_str());

    // unsigned char *cIv = (unsigned char *)malloc(8);
    // memcpy(cIv, sIv.c_str(), 8);

    // std::string encodeString = des_cbc_pkcs5_encrypt(data, key);
    // stlog_debug("encodeString:%s", STL_Text::StringToHexString(encodeString).c_str());
    // encodeString = STL::base64Encode(encodeString);
    // stlog_debug("base64:%s", encodeString.c_str());

    // std::string encodeString1 = EncodeCBCDES3(key, data, cIv);
    // stlog_debug("encodeString1:%s", STL_Text::StringToHexString(encodeString1).c_str());
    // encodeString1 = STL::base64Encode(encodeString1);
    // stlog_debug("base641:%s", encodeString1.c_str());

    // unsigned char uc_key[24];
    // memcpy(uc_key, key.c_str(), 24);
    // unsigned char uc_iv[] = {'1', '2', '3', '4', '5', '6', '7', '8'};
    // unsigned char intext[] = {'j', 'u', 'l', 'o', 'n', 'g', 2, 2};

    // do_encrypt(EVP_des_ede3_cbc(), intext, uc_key, uc_iv);
    return 0;
}
